<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <p>
        <input type="text" id="user">
    </p>
    <p>
        <input type="text" id="pwd">
    </p>
    <p>
       <button id="btn">登录</button>
    </p>
</body>
<script src="./axios.js"></script>
<script>
    const user=document.getElementById('user')
    const pwd=document.getElementById('pwd')
    const btn=document.getElementById('btn')

    btn.addEventListener('click',()=>{
        axios.post('/login',{
            userName:user.value,
            passWord:pwd.value
        }).then((res) => {
            if(res.data.token){
                sessionStorage.setItem('token',res.data.token)
                location.href='./home.html'
            }
        })
    })
</script>
</html>